import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { BuffItem } from "../avatar/BuffItem";
import { ObjectItem } from "../treasure/ObjectItem";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Language } from "../../../../extend/language/Language";
import { ItemData } from "../../resource/info/ItemData";
import { SkillStateConfig } from "../../resource/SkillStateConfig";
import { BuffInfo } from "../avatar/BuffInfo";
import { EffectManager } from "../../manager/EffectManager";
import { Global } from "../../../../com/gengine/global/Global";
import { FlyToNavbarTool } from "../award/FlyToNavbarTool";
import { GButton } from "../../../../com/mui/controls/GButton";
import { LineBox } from "../guide/LineBox";
type int = number;
//class AdoreOptItem
    
    export  class AdoreOptItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        public get isAdore(): Boolean
        {
            return this._isAdore;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 150, 85, this, ImagesConst.RechargeBottom);
            this._buffBg = ObjCreate.createBitmap(ImagesConst.PackItemBg, 33, 8, this);
            this._buffItem = new BuffItem();
            this._buffItem.setSize(33, 33);
            this._buffItem.move(35, 10);
            addChild(this._buffItem);
            this._item = new ObjectItem();
            this._item.setSize(33, 33);
            this._item.move(80, 10);
            addChild(this._item);
            this._btn = ObjCreate.createGButton("", 30, 50, 90, 25, this, "ButtonRed");
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._isAdore = true;
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossAdoreToAdore, this._type));
            return;
        }

        public updateItem(arg1: int, arg2: int, arg3: int, arg4: string): void
        {
            this._type = arg1;
            var loc1="";
            var loc2="";
            var loc5=arg1;
            switch (loc5) 
            {
                case 0:
                {
                    loc1 = Language.getString(36357);
                    loc2 = Language.getString(36363);
                    break;
                }
                case 1:
                {
                    loc1 = Language.getStringByParam(36358, 10);
                    loc2 = Language.getString(36364);
                    break;
                }
                case 2:
                {
                    loc1 = Language.getStringByParam(36358, 30);
                    loc2 = Language.getString(36365);
                    break;
                }
            }
            this._btn.label = loc1;
            this._btn.toolTipData = loc2;
            if (arg2 == 0) 
            {
                this._item.visible = false;
                this._buffBg.x = 56;
                this._buffItem.x = 58;
            }
            else 
            {
                this._item.itemData = new ItemData(arg2);
                this._item.setAmountLabel(arg4);
            }
            var loc3=SkillStateConfig.instance.getInfoByName(arg3);
            var loc4;
            (loc4 = new BuffInfo()).tstate = loc3;
            this._buffItem.buffInfo = loc4;
            return;
        }

        public guideAdore(arg1: Boolean): void
        {
            if (arg1) 
            {
                if (this._lineBox) 
                {
                    EffectManager.disposeLineBox(this._lineBox);
                }
            }
            else 
            {
                if (this._lineBox == null) 
                {
                    this._lineBox = EffectManager.getLineBox(94, 29);
                }
                this._lineBox.x = this._btn.x - 2;
                this._lineBox.y = this._btn.y - 2;
                addChild(this._lineBox);
            }
            return;
        }

        public updateItemState(arg1: int): void
        {
            if (arg1 == 0 || Global.isDebugModle) 
            {
                this._btn.enabled = true;
            }
            else 
            {
                this._btn.enabled = false;
            }
            return;
        }

        public flyBitmap(): void
        {
            var loc1=null;
            var loc2=null;
            if (this._isAdore) 
            {
                this._isAdore = false;
                if (this._item && this._item.visible) 
                {
                    FlyToNavbarTool.flyToBackPack(this._item.bitmapdata, localToGlobal(new Object /* flash.geom.Point */(this._item.x, this._item.y)));
                }
                if (this._buffItem) 
                {
                    loc1 = new Object /* flash.geom.Point */(this._buffItem.x, this._buffItem.y);
                    loc2 = new Object /* flash.geom.Point */(130, 100);
                    FlyToNavbarTool.flyToAnyPoint(this._buffItem.bitmapdata, localToGlobal(loc1), loc2, this.flyCallBack);
                }
            }
            return;
        }

        /* internal  */flyCallBack(arg1: Object /* flash.display.Bitmap */): void
        {
            if (arg1 && arg1.parent) 
            {
                arg1.parent.removeChild(arg1);
                arg1 = null;
            }
            return;
        }

        /* internal */ /* var */_code: int;

        /* internal */ /* var */_type: int=0;

        /* internal */ /* var */_item: ObjectItem;

        /* internal */ /* var */_buffItem: BuffItem;

        /* internal */ /* var */_btn: GButton;

        /* internal */ /* var */_buffBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isAdore: Boolean=false;

        /* internal */ /* var */_lineBox: LineBox;
    }
